import java.util.*;

class RandomIterator implements Iterator<Integer> {
	private int maxCount, count, from, to;
	private Random random;

	public RandomIterator(RandomIterable iter) {
		this.maxCount = iter.count;
		this.count = 0;
		this.from = iter.from;
		this.to = iter.to;
		this.random = new Random();
	}

	public boolean hasNext() {
		this.count++;

		return this.count <= this.maxCount;
	}

	public Integer next() {
		return random.nextInt(this.to - this.from + 1) + this.from;
	}

	public void remove() {
		throw new UnsupportedOperationException();
	}
}
